import axios from 'axios'
import { defineStore } from 'pinia'

const useCinemaStore = defineStore('cinema', {
    state: () => ({
        cinemaList: []
    }),
    actions: {
        async getCinemaList() {
            var res = await axios({
                url: 'https://m.maizuo.com/gateway?cityId=110100&ticketFlag=1&k=4160775',
                headers: {
                    'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.1","e":"17089542072373175589470209","bc":"110100"}',
                    'X-Host': 'mall.film-ticket.cinema.list',
                }
            })
            // console.log('store');
            this.cinemaList = res.data.data.cinemas
        }
    },
    getters: {  //相当于计算属性
        filterCinemaList(state) {
            return (type) => {
                return state.cinemaList.filter(item => item.eTicketFlag === type)
            }
        }
    }
})
export default useCinemaStore